<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机点名</title>
    <style>
        div{
            width: 100px;
            height: 90px;
            border: 1px solid red;
        }
    </style>
</head>

<body>
    <div>
        
    </div>
    <button onclick="">随机点名</button>
    <script>
        //1.获取元素对象
        let Div=document.querySelector('div')
        let btn=document.querySelector('button')
        //2.随机函数生成随机数
        function getRandom(min,max){
            console.log(Math.random())
            return(Math.floor(Math.random() * (max - min + 1)) + min)
            
        }
         // 声明一个数组
         let arr = ['刘备', '曹操', 'pink老师']
         //事件源进行事件监听
         btn.addEventListener('click',function(){
             let random=getRandom(0,arr.length-1)
             console.log(random);
             Div.innerHTML=arr[random]
             arr.splice(random,1)
             if(arr.length==0){
                 btn.disabled=true
                 
             }
         })
    </script>
</body>
</html>